@echo off
rem 		This batch file builds a mathlink executable file for extending Mathematica using
rem 		functions written in c or c++
rem		After setup batch file calls mingw32-make -f batch_helper.mak
rem		the project specific setup is in the makefile

rem	***	User configuration settings here   ***
set version=VC8
set VC71root="C:\Program Files\Microsoft Visual C++ Toolkit 2003"
set VC8root="C:\Program Files\Microsoft Visual Studio 8\VC"
set VC9root="C:\Program Files\Microsoft Visual Studio 9.0\VC"
set SDKroot="C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2"
rem 	***	End user configuration settings  ***

rem use setlocal for now instead of testing setup atleast for now
setlocal
cd /d %~dp0
if "%1"=="VC8" set version=%1& shift
if "%1"=="VC71" set version=%1& shift
if "%1"=="VC9" set version=%1& shift
if "%1"=="MinGW" set version=%1& shift
if "%1"=="MinGW421" set version=%1& shift
if "%1"=="allversions" set version=%1& shift

echo version is "%version%" > logs\make_batch_%version%.log
echo parameters to pass to makefile are "%1" "%2" "%3" >> logs\make_batch_%version%.log

call :setup%version% >> logs\make_batch_%version%.log
mingw32-make -f makefile version=%version% %1 %2 %3
goto :EOF

:setupVC71
echo setting up paths for version VC71 (Toolkit 2003)
call %VC71root%\vcvars32.bat
call :setupSDK
goto :EOF

:setupVC8
echo setting up paths for version VC8 (express 2005)
call %VC8root%\vcvarsall.bat x86
call :setupSDK
goto :EOF

:setupVC9
rem  Call as function using call :setupVC9
echo setting up paths for VC9 (note SDK included)
call %VC9root%\vcvarsall.bat x86
goto :EOF

:setupSDK
rem Latest SDK seems to be fine for all compilers
echo setting up SDK
call %SDKroot%\SetEnv.cmd /XP32
goto :EOF

:setupMinGW
goto :EOF
:setupMinGW421
goto :EOF

:setupallversions
rem iterate through versions
echo iterating through all versions
echo not yet implemented
goto :EOF
